{% load staticfiles %}
<div id="jifenChart" style="width:auto;height:450px;"></div>
   {% csrf_token %}
<script type="text/javascript">

function jifenStatistic() {

	var xData = null;
	var yData = null;

	$.ajax({
		url: "/jifenStatistic",
		type: "post",
        data: {
		    "csrfmiddlewaretoken": $('input[name="csrfmiddlewaretoken"]').val()
        },
		dataType: "json",
		success: function(data) {
			obj = data;
			xData = obj.xData;
			yData = obj.yData;
			 // 初始化图表标签
		    var myChart = echarts.init(document.getElementById('jifenChart'));
		    var options={
		        //定义一个标题
		        title:{
		            text: '比赛积分统计图'
		        },
		        legend:{
		            data:['积分']
		        },
		        tooltip : {
		            trigger: 'axis',
		            formatter: "{c}分"
		        },
		        //X轴设置
		        xAxis:{
		            data:xData
		        },
		        yAxis:{
		        },
		        //name=legend.data的时候才能显示图例
		        series:[{
		            name:'积分',
		            type:'bar',
		            barWidth: 30,//固定柱子宽度
		            data:yData
		        }]
		    };
		    myChart.setOption(options);
		}
	});
}

jifenStatistic();

</script>

<script type="text/javascript" src="{% static 'js/echarts.min.js' %}"></script>



